const Component = require("../model/component.model");

class ComponentService {
  // 获取组件列表
  async getComponentList(where) {
    const res = await Component.findAll({ where });
    if (!res.length) return res;
    return res.map((i) => i.dataValues);
  }

  // 批量创建组件
  async createComponentList(componentList) {
    return await Component.bulkCreate(componentList);
  }

  // 批量彻底删除组件
  async deleteComponentList(where) {
    return await Component.destroy({ where });
  }
}

module.exports = new ComponentService();
